package com.xinxi11.project.qx.beans;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.xinxi11.module.core.entity.RecordSupport;

/**
 * 角色管理 1.根角色中,普通角色主键为1,管理员角色主键为2 2.管理员的子角色的ID为2001,2002,2003,....,2999
 * 3.管理员的子角色(2001)的子角色为2001001,2001002,2001003,...,2001999.其它角色以此类推.
 * 4.角色长度限制在50个字符以内,层级最大为17级.第一级的长度为1
 */
@Entity
@Table(name = "qx_role")
public class QxRole extends RecordSupport<String> {

	private static final long serialVersionUID = 7998525403950645205L;
	/** 角色层级,最大为17.因为每级为3个字符,主键长度为50 **/
	private Integer level;
	/** 角色名称 **/
	private String name;
	/** 父角色ID **/
	private String parentId;
	/** Default 1,--1:普通权限组;2:管理员权限组 **/
	private String type;
	/** 生效时间 **/
	private Timestamp startDate;
	/** 失效时间 **/
	private Timestamp endDate;
	/** 角色的部门限制范围 **/
	private Integer unitId;
	/** 授权范围.1:禁止向下授权(默认),2:允许向下授权 **/
	private Integer isLimit;
	/** 排序,仅限于同级别排序 **/
	private Integer sort;

	// 父角色名字
	private String parentRoleName;
	// 部门名称
	private String unitName;

	@Transient
	public String getUnitName() {
		return unitName;
	}

	public void setUnitName(String unitName) {
		this.unitName = unitName;
	}

	@Transient
	public String getParentRoleName() {
		return parentRoleName;
	}

	public void setParentRoleName(String parentRoleName) {
		this.parentRoleName = parentRoleName;
	}

	/** default constructor */
	public QxRole() {
	}

	/** minimal constructor */
	public QxRole(String id) {
		this.id = id;
	}

	@Id
	@Column(name = "id", unique = true, nullable = false, length = 50)
	public String getId() {
		return this.id;
	}

	@Column(name = "level")
	public Integer getLevel() {
		return this.level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	@Column(name = "name", length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "parentId", length = 50)
	public String getParentId() {
		return this.parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	@Column(name = "type", length = 10)
	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name = "startDate", length = 23)
	public Timestamp getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Timestamp startDate) {
		this.startDate = startDate;
	}

	@Column(name = "endDate", length = 23)
	public Timestamp getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Timestamp endDate) {
		this.endDate = endDate;
	}

	@Column(name = "unitId")
	public Integer getUnitId() {
		return this.unitId;
	}

	public void setUnitId(Integer unitId) {
		this.unitId = unitId;
	}

	@Column(name = "isLimit")
	public Integer getIsLimit() {
		return this.isLimit;
	}

	public void setIsLimit(Integer isLimit) {
		this.isLimit = isLimit;
	}

	@Column(name = "sort")
	public Integer getSort() {
		return this.sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
}